package srjava.messages;

import java.io.IOException;
import java.io.StringReader;

public class CordinatorInfo implements Serializable {
	Address address;
	SrString serverName;
	
	public CordinatorInfo() {
		address = new Address();
		serverName = new SrString();
	}

	public CordinatorInfo(Address address, SrString serverName) {
		this.address = address;
		this.serverName = serverName;
	}

	public Address getAddress() {
		return address;
	}

	public void setAddress(Address address) {
		this.address = address;
	}

	public SrString getServerName() {
		return serverName;
	}

	public void setServerName(SrString serverName) {
		this.serverName = serverName;
	}

	@Override
	public String serialize() {
		String pom = address.serialize() + serverName.serialize();
		return pom;
	}

	@Override
	public void deSerialize(StringReader s) throws IOException {
		address.deSerialize(s);
		serverName.deSerialize(s);
	}
	
	public static void main(String [ ] args)
	{
		CordinatorInfo ad = new CordinatorInfo(new Address(new SrString("mama"), 5), new SrString("kalafior"));
		System.out.println(ad.serialize());
		try {
			ad.deSerialize(new StringReader("5 mamma 7 12 kalafior 123 "));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println(ad.serialize());
	}

}
